package com.cxhc.app.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cxhc.system.domain.app.CmLike;
import com.cxhc.system.service.app.ICmLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.utils.poi.ExcelUtil;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 点赞Controller
 * 
 * @author Dhq
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/api/like")
public class ApiCmLike extends BaseController
{
    @Autowired
    private ICmLikeService cmLikeService;

    /**
     * 查询点赞列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmLike cmLike)
    {
        startPage();
        List<CmLike> list = cmLikeService.selectCmLikeList(cmLike);
        return getDataTable(list);
    }

    /**
     * 导出点赞列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmLike cmLike)
    {
        List<CmLike> list = cmLikeService.selectCmLikeList(cmLike);
        ExcelUtil<CmLike> util = new ExcelUtil<CmLike>(CmLike.class);
        util.exportExcel(response, list, "点赞数据");
    }

    /**
     * 获取点赞详细信息
     */
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cmLikeService.selectCmLikeById(id));
    }

    /**
     * 新增点赞
     */
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody CmLike cmLike)
    {
        return toAjax(cmLikeService.insertCmLike(cmLike));
    }

    /**
     * 修改点赞
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody CmLike cmLike)
    {
        return toAjax(cmLikeService.updateCmLike(cmLike));
    }

    /**
     * 删除点赞
     */
	@DeleteMapping("/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(cmLikeService.deleteCmLikeById(id));
    }
}
